<!--
 * @Author: your name
 * @Date: 2021-08-13 15:49:01
 * @LastEditTime: 2022-01-27 17:45:16
 * @LastEditTime: 2021-11-08 16:34:08
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \jinfeng_up\src\components\seriousDelateDialog\seriousDelateDialog.vue
-->
<template>
  <div>
    <CommonDialog
      title="持续处理"
      width="75%"
      v-bind:dialogVisible="seriousDelateVisible"
      @on-change-dialogVisible="seriousDelateChange"
      top="5vh"
      class="createTask"
    >
      <template #body>
        <el-form
          class="seriousForm"
          ref="seriousFormRef"
          label-position="top"
          :model="seriousForm"
          :rules="seriousFormRules"
          size="mini"
          label-width="80px"
        >
          <el-row :gutter="10">
            <el-col :span="24">
              <el-form-item label="标题" prop="title">
                <el-input disabled v-model="seriousForm.title" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item label="反馈ID" prop="feedId">
                <el-input disabled v-model="seriousForm.feedId" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="创建天数" prop="createDay">
                <el-input disabled v-model="seriousForm.createDay" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="12">
              <el-form-item label="责任人" prop="currentStageUser">
                <el-input disabled v-model="seriousForm.currentStageUser" class="changeHeight"></el-input>
              </el-form-item>
            </el-col>

          </el-row>
          <el-row :gutter="10">
            <el-col :span="24">
              <el-form-item label="当前进展" prop="currentProgress">
                <!-- <socialUpload
                  :contentDefault="seriousForm.currentProgress"
                  @getContent="getUpdateContentOne"
                ></socialUpload> -->
                <el-input v-model="seriousForm.currentProgress" type="textarea" class="continuousProcessing"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="24">
              <el-form-item label="下一步措施" prop="nextPlan">
                <!-- <socialUpload
                  :contentDefault="seriousForm.nextPlan"
                  @getContent="getUpdateContentTwo"
                ></socialUpload> -->
                <el-input v-model="seriousForm.nextPlan" class="continuousProcessing" type="textarea"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <!-- <el-steps :space="180" :active="4">
          <el-step v-for="(item, index) in stageList" :key="index" :title="item.stageName"></el-step>
        </el-steps> -->
      </template>
      <template #dialog_footer>
        <el-button size="small" @click="seriousDelateChange">关 闭</el-button>
        <el-button type="primary" @click="confrimSerious" size="small">保 存</el-button>
      </template>
    </CommonDialog>
  </div>
</template>

<script>
// import socialUpload from '../socialUpload/socialUpload.vue'
import CommonDialog from '@/components/commonDialog/commonDialog.vue'
import { FeedBack } from '@/api/feedBack/server'
export default {
    name: '',
    components: {
        CommonDialog
    // socialUpload
    },
    props: {},
    data() {
        return {
            //   会议ID
            meetingRecordId: '',

            //     反馈ID
            feedBackId: '',

            seriousDelateVisible: false,
            seriousForm: {
                title: '', // 标题
                feedId: '', // 反馈ID
                createDay: null, // 创建天数
                currentStageUser: '', // 责任人
                currentProgress: '', // 当前进展
                nextPlan: '' // 下一步计划
            },
            // 表单验证规则

            seriousFormRules: {
                currentProgress: [{ required: true, message: '请输入当前进展', trigger: 'blur' }],
                nextPlan: [{ required: true, message: '请输入下一步措施', trigger: 'blur' }]
            },

            //   阶段列表
            stageList: [],
            // 当前阶段
            stageNum: null
        }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
        seriousDelateChange(val) {
            this.seriousDelateVisible = val
            this.seriousForm = {
                title: '', // 标题
                feedId: '', // 反馈ID
                createDay: null, // 创建天数
                currentStageUser: '', // 责任人
                currentProgress: '', // 当前进展
                nextPlan: '' // 下一步计划
            }
        },

        show(string) {
            const row = JSON.parse(string)
            this.seriousDelateVisible = true
            this.seriousForm.feedId = row.feedBackNumber
            this.meetingRecordId = row.meetingRecordId
            this.feedBackId = row.feedBackId
            this.getCreatorMessage(this.seriousForm.feedId)
            // this.GetFeedBackStage(this.feedBackId)
        },

        /* 根据反馈ID获取相关信息 */
        async getCreatorMessage(id) {
            //   let id = this.feedBackNumber;
            try {
                const result = await FeedBack.GetFeedBackOverTime({ feedBackNumber: id })

                if (result.success) {
                    this.seriousForm.createDay = result.data.createDay
                    this.seriousForm.title = result.data.title
                    this.seriousForm.currentStageUser = result.data.currentStageUser
                }
            } catch (err) {
                console.log(err)
            }
        },

        confrimSerious() {
            this.$refs['seriousFormRef'].validate(valid => {
                if (valid) {
                    this.saveAsync()
                } else {
                    console.log('error submit!!')
                    return false
                }
            })
        },

        // 持续处理保存
        async saveAsync() {
            console.log(this.meetingRecordId)
            const objparams = {

                currentProgress: this.seriousForm.currentProgress,
                id: this.meetingRecordId,
                nextPlan: this.seriousForm.nextPlan
            }

            try {
                const result = await FeedBack.Pocessing(objparams)

                if (result.success) {
                    this.seriousForm = {
                        title: '', // 标题
                        feedId: '', // 反馈ID
                        createDay: null, // 创建天数
                        currentStageUser: '', // 责任人
                        currentProgress: '', // 当前进展
                        nextPlan: '' // 下一步计划
                    }
                    this.$emit('refreshPage')
                    this.seriousDelateVisible = false
                }
            } catch (err) {
                console.log(err)
            }
        },

        // 获取阶段
        async GetFeedBackStage() {
            try {
                const result = await FeedBack.GetFeedBackStage({ feedBackId: this.feedBackId })

                if (result.success) {
                    this.stageList = result.data
                    this.stageNum = this.stageList.length
                    this.$emit('refreshPage')
                }
            } catch (err) {
                console.log(err)
            }
        },
        getUpdateContentOne(Value) {
            this.seriousForm.currentProgress = Value
        },
        getUpdateContentTwo(Value) {
            this.seriousForm.nextPlan = Value
        }
    }
}
</script>

<style scoped lang="less">
::v-deep .el-input--mini .el-input__inner {
  height: 35px;
}
.changeHeight {
  height: 30px;
}

::v-deep .continuousProcessing textarea {
  height: 150px;
  background: #ffffff;
  border: 1px solid #dadee0;
  border-radius: 2px;
}
</style>
